<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRedEnvelopesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('red_envelopes', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('userid')->comment('用户id');
            $table->decimal('amount', 16,2)->comment('红包金额');
            $table->decimal('hqamount', 16, 2)->default(0.00)->comment('总部红包金额');
            $table->decimal('agentamount', 16, 2)->default(0.00)->comment('代理商红包金额');
            $table->decimal('minimumamount', 16,2)->comment('最低使用金额');
            $table->integer('shopid')->default(0)->comment('商家id');
            $table->integer('cityid')->default(1)->comment('城市id');
            $table->dateTime('starttime')->comment('开始时间');
            $table->dateTime('endtime')->comment('截止时间');
            $table->dateTime('usetime')->comment('使用时间');
            $table->tinyInteger('status')->comment('状态');
            $table->string('type', 32)->default('')->comment('类型');
            $table->integer('firstclassid')->default(0)->comment('一级分类id');
            $table->integer('secondclassid')->default(0)->comment('二级分类id');
            $table->string('firstclassname')->default('')->comment('一级分类名称');
            $table->string('secondclassname')->default('')->comment('二级分类名称');
            $table->string('position')->default('')->comment('投放位置，首页、充值、订单等');
            $table->string('info', 256)->nullable()->comment('预留');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('red_envelopes');
    }
}
